const Lang = imports.lang;
const Signals = imports.signals;
-function Task() {
- this._init.apply(this, arguments);
-}
+const Task = new Lang.Class({
+ Name: 'Task',
-Task.prototype = {
_init: function(scope, handler) {
if (scope)
this.scope = scope;
return null;
},
-};
+});
Signals.addSignalMethods(Task.prototype);
-function Hold() {
- this._init.apply(this, arguments);
-}
-
-Hold.prototype = {
- __proto__: Task.prototype,
+const Hold = new Lang.Class({
+ Name: 'Hold',
+ Extends: Task,
_init: function() {
- Task.prototype._init.call(this,
- this,
- function () {
- return this;
- });
+ this.parent(this, function () {
+ return this;
+ });
this._acquisitions = 1;
},
isAcquired: function() {
return this._acquisitions > 0;
}
-}
+});
Signals.addSignalMethods(Hold.prototype);
-function Batch() {
- this._init.apply(this, arguments);
-}
-
-Batch.prototype = {
- __proto__: Task.prototype,
+const Batch = new Lang.Class({
+ Name: 'Batch',
+ Extends: Task,
_init: function(scope, tasks) {
- Task.prototype._init.call(this);
+ this.parent();
this.tasks = [];
cancel: function() {
this.tasks = this.tasks.splice(0, this._currentTaskIndex + 1);
}
-
-};
+});
Signals.addSignalMethods(Batch.prototype);
-function ConcurrentBatch() {
- this._init.apply(this, arguments);
-}
-
-ConcurrentBatch.prototype = {
- __proto__: Batch.prototype,
-
- _init: function(scope, tasks) {
- Batch.prototype._init.call(this, scope, tasks);
- },
+const ConcurrentBatch = new Lang.Class({
+ Name: 'ConcurrentBatch',
+ Extends: Batch,
process: function() {
let hold = this.runTask();
// concurrently.
this.nextTask();
}
-};
+});
Signals.addSignalMethods(ConcurrentBatch.prototype);
-function ConsecutiveBatch() {
- this._init.apply(this, arguments);
-}
-
-ConsecutiveBatch.prototype = {
- __proto__: Batch.prototype,
-
- _init: function(scope, tasks) {
- Batch.prototype._init.call(this, scope, tasks);
- },
+const ConsecutiveBatch = new Lang.Class({
+ Name: 'ConsecutiveBatch',
+ Extends: Batch,
process: function() {
let hold = this.runTask();
this.nextTask();
}
}
-};
+});
Signals.addSignalMethods(ConsecutiveBatch.prototype);
}
};
-function SwitcherList(squareItems) {
- this._init(squareItems);
-}
+const SwitcherList = new Lang.Class({
+ Name: 'SwitcherList',
-SwitcherList.prototype = {
_init : function(squareItems) {
this.actor = new Shell.GenericContainer({ style_class: 'switcher-list' });
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
// Clip the area for scrolling
this._clipBin.set_clip(0, -topPadding, (this.actor.allocation.x2 - this.actor.allocation.x1) - leftPadding - rightPadding, this.actor.height + bottomPadding);
}
-};
+});
Signals.addSignalMethods(SwitcherList.prototype);
}
};
-function AppSwitcher() {
- this._init.apply(this, arguments);
-}
-
-AppSwitcher.prototype = {
- __proto__ : SwitcherList.prototype,
+const AppSwitcher = new Lang.Class({
+ Name: 'AppSwitcher',
+ Extends: SwitcherList,
_init : function(localApps, otherApps, altTabPopup) {
- SwitcherList.prototype._init.call(this, true);
+ this.parent(true);
// Construct the AppIcons, add to the popup
let activeWorkspace = global.screen.get_active_workspace();
_allocate: function (actor, box, flags) {
// Allocate the main list items
- SwitcherList.prototype._allocate.call(this, actor, box, flags);
+ this.parent(actor, box, flags);
let arrowHeight = Math.floor(this.actor.get_theme_node().get_padding(St.Side.BOTTOM) / 3);
let arrowWidth = arrowHeight * 2;
this._arrows[this._curApp].remove_style_pseudo_class('highlighted');
}
- SwitcherList.prototype.highlight.call(this, n, justOutline);
+ this.parent(n, justOutline);
this._curApp = n;
if (this._curApp != -1) {
if (appIcon.cachedWindows.length == 1)
arrow.hide();
}
-};
-
-function ThumbnailList(windows) {
- this._init(windows);
-}
+});
-ThumbnailList.prototype = {
- __proto__ : SwitcherList.prototype,
+const ThumbnailList = new Lang.Class({
+ Name: 'ThumbnailList',
+ Extends: SwitcherList,
_init : function(windows) {
- SwitcherList.prototype._init.call(this);
+ this.parent(false);
let activeWorkspace = global.screen.get_active_workspace();
// Make sure we only do this once
this._thumbnailBins = new Array();
}
-};
+});
function _drawArrow(area, side) {
let themeNode = area.get_theme_node();
}
};
-function AppSearchProvider() {
- this._init();
-}
-
-AppSearchProvider.prototype = {
- __proto__: Search.SearchProvider.prototype,
+const AppSearchProvider = new Lang.Class({
+ Name: 'AppSearchProvider',
+ Extends: Search.SearchProvider,
_init: function() {
- Search.SearchProvider.prototype._init.call(this, _("APPLICATIONS"));
+ this.parent(_("APPLICATIONS"));
+
this._appSys = Shell.AppSystem.get_default();
},
let icon = new AppWellIcon(app);
return icon.actor;
}
-};
-
-function SettingsSearchProvider() {
- this._init();
-}
+});
-SettingsSearchProvider.prototype = {
- __proto__: Search.SearchProvider.prototype,
+const SettingsSearchProvider = new Lang.Class({
+ Name: 'SettingsSearchProvider',
+ Extends: Search.SearchProvider,
_init: function() {
- Search.SearchProvider.prototype._init.call(this, _("SETTINGS"));
+ this.parent(_("SETTINGS"));
+
this._appSys = Shell.AppSystem.get_default();
this._gnomecc = this._appSys.lookup_app('gnome-control-center.desktop');
},
let icon = new AppWellIcon(app);
return icon.actor;
}
-};
-
-function AppIcon(app, params) {
- this._init(app, params);
-}
+});
-AppIcon.prototype = {
- __proto__: IconGrid.BaseIcon.prototype,
+const AppIcon = new Lang.Class({
+ Name: 'AppIcon',
+ Extends: IconGrid.BaseIcon,
_init : function(app, params) {
this.app = app;
let label = this.app.get_name();
- IconGrid.BaseIcon.prototype._init.call(this,
- label,
- params);
+ this.parent(label, params);
},
createIcon: function(iconSize) {
return this.app.create_icon_texture(iconSize);
}
-};
+});
function AppWellIcon(app, iconParams, onActivateOverride) {
this._init(app, iconParams, onActivateOverride);
/* Searches for and returns contacts */
-function ContactSearchProvider() {
- this._init();
-}
-
-ContactSearchProvider.prototype = {
- __proto__: Search.SearchProvider.prototype,
+const ContactSearchProvider = new Lang.Class({
+ Name: 'ContactSearchProvider',
+ Extends: Search.SearchProvider,
_init: function() {
- Search.SearchProvider.prototype._init.call(this, _("CONTACTS"));
+ this.parent(_("CONTACTS"));
this._contactSys = Shell.ContactSystem.get_default();
},
activateResult: function(id, params) {
launchContact(id);
}
-};
+});
}
};
-function CtrlAltTabSwitcher(items) {
- this._init(items);
-}
-
-CtrlAltTabSwitcher.prototype = {
- __proto__ : AltTab.SwitcherList.prototype,
+const CtrlAltTabSwitcher = new Lang.Class({
+ Name: 'CtrlAltTabSwitcher',
+ Extends: AltTab.SwitcherList,
_init : function(items) {
- AltTab.SwitcherList.prototype._init.call(this, true);
+ this.parent(true);
for (let i = 0; i < items.length; i++)
this._addIcon(items[i]);
this.addItem(box, text);
}
-};
+});
// A container like StBin, but taking the child's scale into account
// when requesting a size
-function DashItemContainer() {
- this._init();
-}
+const DashItemContainer = new Lang.Class({
+ Name: 'DashItemContainer',
-DashItemContainer.prototype = {
_init: function() {
this.actor = new Shell.GenericContainer({ style_class: 'dash-item-container' });
this.actor.connect('get-preferred-width',
get childOpacity() {
return this._childOpacity;
}
-};
+});
-function RemoveFavoriteIcon() {
- this._init();
-}
-
-RemoveFavoriteIcon.prototype = {
- __proto__: DashItemContainer.prototype,
+const RemoveFavoriteIcon = new Lang.Class({
+ Name: 'RemoveFavoriteIcon',
+ Extends: DashItemContainer,
_init: function() {
- DashItemContainer.prototype._init.call(this);
+ this.parent();
this._iconBin = new St.Bin({ style_class: 'remove-favorite' });
this._iconActor = null;
return true;
}
-};
+});
-
-function DragPlaceholderItem() {
- this._init();
-}
-
-DragPlaceholderItem.prototype = {
- __proto__: DashItemContainer.prototype,
+const DragPlaceholderItem = new Lang.Class({
+ Name: 'DragPlaceholderItem',
+ Extends: DashItemContainer,
_init: function() {
- DashItemContainer.prototype._init.call(this);
+ this.parent();
this.setChild(new St.Bin({ style_class: 'placeholder' }));
}
-};
-
+});
function Dash() {
this._init();
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const DocInfo = imports.misc.docInfo;
+const Lang = imports.lang;
const Params = imports.misc.params;
const Search = imports.ui.search;
-
-function DocSearchProvider() {
- this._init();
-}
-
-DocSearchProvider.prototype = {
- __proto__: Search.SearchProvider.prototype,
+const DocSearchProvider = new Lang.Class({
+ Name: 'DocSearchProvider',
+ Extends: Search.SearchProvider,
_init: function(name) {
- Search.SearchProvider.prototype._init.call(this, _("RECENT ITEMS"));
+ this.parent(_("RECENT ITEMS"));
this._docManager = DocInfo.getDocManager();
},
getSubsearchResultSet: function(previousResults, terms) {
return this._docManager.subsearch(previousResults, terms);
}
-};
+});
const ICON_SIZE = 48;
-function BaseIcon(label, createIcon) {
- this._init(label, createIcon);
-}
+const BaseIcon = new Lang.Class({
+ Name: 'BaseIcon',
-BaseIcon.prototype = {
_init : function(label, params) {
params = Params.parse(params, { createIcon: null,
setSizeManually: false,
this._createIconTexture(size);
}
-};
+});
function IconGrid(params) {
this._init(params);
const Signals = imports.signals;
const St = imports.gi.St;
-function Link(props) {
- this._init(props);
-}
+const Link = new Lang.Class({
+ Name: 'Link',
-Link.prototype = {
_init : function(props) {
let realProps = { reactive: true,
track_hover: true,
this.actor = new St.Button(realProps);
}
-};
-
+});
Signals.addSignalMethods(Link.prototype);
}
}
-function ObjLink(o, title) {
- this._init(o, title);
-}
-
-ObjLink.prototype = {
- __proto__: Link.Link,
+const ObjLink = new Lang.Class({
+ Name: 'ObjLink',
+ Extends: Link.Link,
_init: function(o, title) {
let text;
text = objectToString(o);
text = GLib.markup_escape_text(text, -1);
this._obj = o;
- Link.Link.prototype._init.call(this, { label: text });
+
+ this.parent({ label: text });
this.actor.get_child().single_line_mode = true;
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
},
_onClicked: function (link) {
Main.lookingGlass.inspectObject(this._obj, this.actor);
}
-};
+});
function Result(command, o, index) {
this._init(command, o, index);
* @iconFactory: A JavaScript callback which will create an icon texture given a size parameter
* @launch: A JavaScript callback to launch the entry
*/
-function PlaceInfo(id, name, iconFactory, launch) {
- this._init(id, name, iconFactory, launch);
-}
+const PlaceInfo = new Lang.Class({
+ Name: 'PlaceInfo',
-PlaceInfo.prototype = {
_init: function(id, name, iconFactory, launch) {
this.id = id;
this.name = name;
isRemovable: function() {
return false;
}
-};
+});
// Helper function to translate launch parameters into a GAppLaunchContext
function _makeLaunchContext(params)
return launchContext;
}
-function PlaceDeviceInfo(mount) {
- this._init(mount);
-}
-
-PlaceDeviceInfo.prototype = {
- __proto__: PlaceInfo.prototype,
+const PlaceDeviceInfo = new Lang.Class({
+ Name: 'PlaceDeviceInfo',
+ Extends: PlaceInfo,
_init: function(mount) {
this._mount = mount;
_("Retry"));
}
}
-};
+});
function PlacesManager() {
this._init();
};
Signals.addSignalMethods(PlacesManager.prototype);
-
-function PlaceSearchProvider() {
- this._init();
-}
-
-PlaceSearchProvider.prototype = {
- __proto__: Search.SearchProvider.prototype,
+const PlaceSearchProvider = new Lang.Class({
+ Name: 'PlaceSearchProvider',
+ Extends: Search.SearchProvider,
_init: function() {
- Search.SearchProvider.prototype._init.call(this, _("PLACES & DEVICES"));
+ this.parent(_("PLACES & DEVICES"));
},
getResultMeta: function(resultId) {
let places = previousResults.map(function (id) { return Main.placesManager.lookupPlaceById(id); });
return this._searchPlaces(places, terms);
}
-};
+});
}
};
-function RunDialog() {
- this._init();
-}
+const RunDialog = new Lang.Class({
+ Name: 'RunDialog',
+ Extends: ModalDialog.ModalDialog,
-RunDialog.prototype = {
-__proto__: ModalDialog.ModalDialog.prototype,
_init : function() {
- ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'run-dialog' });
+ this.parent({ styleClass: 'run-dialog' });
this._lockdownSettings = new Gio.Settings({ schema: LOCKDOWN_SCHEMA });
this._terminalSettings = new Gio.Settings({ schema: TERMINAL_SCHEMA });
if (this._lockdownSettings.get_boolean(DISABLE_COMMAND_LINE_KEY))
return;
- ModalDialog.ModalDialog.prototype.open.call(this);
+ this.parent();
},
-
-};
+});
Signals.addSignalMethods(RunDialog.prototype);
MULTIPLE_PREFIX: 4
};
-function SearchResultDisplay(provider) {
- this._init(provider);
-}
+const SearchResultDisplay = new Lang.Class({
+ Name: 'SearchResultDisplay',
-SearchResultDisplay.prototype = {
_init: function(provider) {
this.provider = provider;
this.actor = null;
activateSelected: function() {
throw new Error('Not implemented');
}
-};
+});
/**
* SearchProvider:
* to the search system, then call registerProvider()
* in SearchSystem with an instance.
*/
-function SearchProvider(title) {
- this._init(title);
-}
+const SearchProvider = new Lang.Class({
+ Name: 'SearchProvider',
-SearchProvider.prototype = {
_init: function(title) {
this.title = title;
this.searchSystem = null;
activateResult: function(id) {
throw new Error('Not implemented');
}
-};
+});
Signals.addSignalMethods(SearchProvider.prototype);
function OpenSearchSystem() {
};
-function GridSearchResults(provider, grid) {
- this._init(provider, grid);
-}
-
-GridSearchResults.prototype = {
- __proto__: Search.SearchResultDisplay.prototype,
+const GridSearchResults = new Lang.Class({
+ Name: 'GridSearchResults',
+ Extends: Search.SearchResultDisplay,
_init: function(provider, grid) {
- Search.SearchResultDisplay.prototype._init.call(this, provider);
+ this.parent(provider);
+
this._grid = grid || new IconGrid.IconGrid({ rowLimit: MAX_SEARCH_RESULTS_ROWS,
xAlign: St.Align.START });
this.actor = new St.Bin({ x_align: St.Align.START });
let targetActor = this._grid.getItemAtIndex(this.selectionIndex);
targetActor._delegate.activate();
}
-};
-
+});
function SearchResults(searchSystem, openSearchSystem) {
this._init(searchSystem, openSearchSystem);
}
});
-function NMDevice() {
- throw new TypeError('Instantanting abstract class NMDevice');
-}
+const NMDevice = new Lang.Class({
+ Name: 'NMDevice',
+ Abstract: true,
-NMDevice.prototype = {
_init: function(client, device, connections) {
this.device = device;
if (device) {
return out;
}
-};
+});
Signals.addSignalMethods(NMDevice.prototype);
-function NMDeviceWired() {
- this._init.apply(this, arguments);
-}
-
-NMDeviceWired.prototype = {
- __proto__: NMDevice.prototype,
+const NMDeviceWired = new Lang.Class({
+ Name: 'NMDeviceWired',
+ Extends: NMDevice,
_init: function(client, device, connections) {
this._autoConnectionName = _("Auto Ethernet");
this.category = NMConnectionCategory.WIRED;
- NMDevice.prototype._init.call(this, client, device, connections);
+ this.parent(client, device, connections);
},
_createSection: function() {
- NMDevice.prototype._createSection.call(this);
+ this.parent();
// if we have only one connection (normal or automatic)
// we hide the connection list, and use the switch to control
}));
return connection;
}
-};
-
-function NMDeviceModem() {
- this._init.apply(this, arguments);
-}
+});
-NMDeviceModem.prototype = {
- __proto__: NMDevice.prototype,
+const NMDeviceModem = new Lang.Class({
+ Name: 'NMDeviceModem',
+ Extends: NMDevice,
_init: function(client, device, connections) {
let is_wwan = false;
}));
}
- NMDevice.prototype._init.call(this, client, device, connections);
+ this.parent(client, device, connections);
},
setEnabled: function(enabled) {
this.statusItem.setStatus(this.getStatusLabel());
}
- NMDevice.prototype.setEnabled.call(this, enabled);
+ this.parent(enabled);
},
get connected() {
this._signalQualityId = 0;
}
- NMDevice.prototype.destroy.call(this);
+ this.parent();
},
_getSignalIcon: function() {
this.section.addMenuItem(this._operatorItem);
}
- NMDevice.prototype._createSection.call(this);
+ this.parent();
},
_clearSection: function() {
this._operatorItem = null;
- NMDevice.prototype._clearSection.call(this);
+ this.parent();
},
_createAutomaticConnection: function() {
'connect-3g', this.device.get_path()]);
return null;
}
-};
-
-function NMDeviceBluetooth() {
- this._init.apply(this, arguments);
-}
+});
-NMDeviceBluetooth.prototype = {
- __proto__: NMDevice.prototype,
+const NMDeviceBluetooth = new Lang.Class({
+ Name: 'NMDeviceBluetooth',
+ Extends: NMDevice,
_init: function(client, device, connections) {
this._autoConnectionName = this._makeConnectionName(device);
this.category = NMConnectionCategory.WWAN;
- NMDevice.prototype._init.call(this, client, device, connections);
+ this.parent(client, device, connections);
},
_createAutomaticConnection: function() {
this._clearSection();
this._createSection();
}
-};
+});
// Not a real device, but I save a lot code this way
-function NMDeviceVPN() {
- this._init.apply(this, arguments);
-}
-
-NMDeviceVPN.prototype = {
- __proto__: NMDevice.prototype,
+const NMDeviceVPN = new Lang.Class({
+ Name: 'NMDeviceVPN',
+ Extends: NMDevice,
_init: function(client) {
// Disable autoconnections
this._autoConnectionName = null;
this.category = NMConnectionCategory.VPN;
- NMDevice.prototype._init.call(this, client, null, [ ]);
+ this.parent(client, null, [ ]);
},
connectionValid: function(connection) {
},
setActiveConnection: function(activeConnection) {
- NMDevice.prototype.setActiveConnection.call(this, activeConnection);
+ this.parent(activeConnection);
this.emit('active-connection-changed');
},
getStatusLabel: function() {
return null;
}
-};
-
-function NMDeviceWireless() {
- this._init.apply(this, arguments);
-}
+});
-NMDeviceWireless.prototype = {
- __proto__: NMDevice.prototype,
+const NMDeviceWireless = new Lang.Class({
+ Name: 'NMDeviceWireless',
+ Extends: NMDevice,
_init: function(client, device, connections) {
this.category = NMConnectionCategory.WIRELESS;
this._apAddedId = device.connect('access-point-added', Lang.bind(this, this._accessPointAdded));
this._apRemovedId = device.connect('access-point-removed', Lang.bind(this, this._accessPointRemoved));
- NMDevice.prototype._init.call(this, client, device, validConnections);
+ this.parent(client, device, validConnections);
},
destroy: function() {
this._apRemovedId = 0;
}
- NMDevice.prototype.destroy.call(this);
+ this.parent();
},
setEnabled: function(enabled) {
},
_clearSection: function() {
- NMDevice.prototype._clearSection.call(this);
+ this.parent();
for (let i = 0; i < this._networks.length; i++)
this._networks[i].item = null;
this._createNetworkItem(apObj, j + activeOffset);
}
},
-};
+});
const NMApplet = new Lang.Class({
Name: 'NMApplet',
const ShellEntry = imports.ui.shellEntry;
const Tweener = imports.ui.tweener;
-function BaseTab(titleActor, pageActor, name, a11yIcon) {
- this._init(titleActor, pageActor, name, a11yIcon);
-}
+const BaseTab = new Lang.Class({
+ Name: 'BaseTab',
-BaseTab.prototype = {
_init: function(titleActor, pageActor, name, a11yIcon) {
this.title = titleActor;
this.page = new St.Bin({ child: pageActor,
_activate: function() {
this.emit('activated');
}
-};
+});
Signals.addSignalMethods(BaseTab.prototype);
-function ViewTab(id, label, pageActor, a11yIcon) {
- this._init(id, label, pageActor, a11yIcon);
-}
-
-ViewTab.prototype = {
- __proto__: BaseTab.prototype,
+const ViewTab = new Lang.Class({
+ Name: 'ViewTab',
+ Extends: BaseTab,
_init: function(id, label, pageActor, a11yIcon) {
this.id = id;
style_class: 'view-tab-title' });
titleActor.connect('clicked', Lang.bind(this, this._activate));
- BaseTab.prototype._init.call(this, titleActor, pageActor, label, a11yIcon);
+ this.parent(titleActor, pageActor, label, a11yIcon);
}
-};
+});
-function SearchTab() {
- this._init();
-}
-
-SearchTab.prototype = {
- __proto__: BaseTab.prototype,
+const SearchTab = new Lang.Class({
+ Name: 'SearchTab',
+ Extends: BaseTab,
_init: function() {
this.active = false;
this._iconClickedId = 0;
this._searchResults = new SearchDisplay.SearchResults(this._searchSystem, this._openSearchSystem);
- BaseTab.prototype._init.call(this,
- this._entry,
- this._searchResults.actor,
- _("Search"),
- 'edit-find');
+ this.parent(this._entry, this._searchResults.actor, _("Search"), 'edit-find');
this._text.connect('text-changed', Lang.bind(this, this._onTextChanged));
this._text.connect('key-press-event', Lang.bind(this, function (o, e) {
},
hide: function() {
- BaseTab.prototype.hide.call(this);
+ this.parent();
// Leave the entry focused when it doesn't have any text;
// when replacing a selected search term, Clutter emits
return false;
}
-};
+});
function ViewSelector() {